package com.kgd.news.ibeetl.func;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.kgd.news.utils.Config;
import com.kgd.news.utils.StringUtils;
import org.beetl.core.Context;
import org.beetl.core.Function;

import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @Email: huangsanm@foxmail.com
 * @Date: 2017/7/26
 * @Time: 下午10:45
 * 查询数据库sys_dict表里面的参数
 * 类似于通用工具一样的东西，可以在html里面直接调用
 */
public class ProjectTittleFunc implements Function {
    private static final String encode = "GBK";//文件的编码格式

    @Override
    public Object call(Object[] objects, Context context) {
        //String args = (String) objects[0];
        //String[] objs = args.split(":");
        String tittle = Config.getPropertiesValue("init.properties", "project_tittle");
        try {
            tittle=   new String(tittle.getBytes("ISO8859-1"), encode);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            tittle = "小程序";
        }
        if (StringUtils.isEmpty(tittle)) {
            tittle = "小程序";
        }
        return tittle;
    }


}
